package com.xiaoshuidi.cloud.module.bpm.framework.bpm.config;

import com.xiaoshuidi.cloud.module.bpm.framework.bpm.core.BpmBusBridge;
import com.xiaoshuidi.cloud.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventPublisher;
import org.springframework.cloud.bus.BusProperties;
import org.springframework.cloud.bus.ServiceMatcher;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * BPM 通用的 Configuration 配置类，提供给 Activiti 和 Flowable
 */
@Configuration(proxyBeanMethods = false)
public class BpmCommonConfiguration {

    @Bean
    public BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher(ApplicationEventPublisher publisher,
                                                                                      ServiceMatcher serviceMatcher) {
        return new BpmProcessInstanceResultEventPublisher(publisher, serviceMatcher);
    }

    @Bean
    public BpmBusBridge streamBusBridge(StreamBridge streamBridge, BusProperties properties) {
        return new BpmBusBridge(streamBridge, properties);
    }

}
